home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / TMENU1.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  2.1 KB  |  73 lines

  1. // tmenu1.cpp: Menu test program
  2.  
  3. #include "wsotxscr.h"
  4. #include "msounit.h"
  5.  
  6. void ExitAction(Wso *, MsgPkt &M)
  7. // Quits the pull-down menu program 
  8. {
  9.   M.RtnCode = ShutDown;
  10. }
  11.  
  12. void PopupAction(Wso *Src, MsgPkt &M)
  13. // Displays a pop-up menu for the menu entry selected 
  14. {  
  15.   Wso *B;
  16.   char Buff[80];
  17.   ((Meso *)Src)->OnClose(M);    // Close the sub-menu 
  18.   M.Code = M.RtnCode;           // Use the return code
  19.   FullScrn->SubMgr->EventStep(M);
  20.   // Create the pop-up window 
  21.   B = new Wso(0x11, WindowStyle, DefColors);
  22.   strcpy(Buff, ((Meso *)Src)->Name);
  23.   strcat(Buff, " Action");
  24.   B->SetSize(B->Panel->TextWidth(Buff), B->Panel->TextHeight(2));
  25.   B->Open(FullScrn, 30, 10);
  26.   B->Panel->HzWrt(0, 0, Buff, 0);
  27.   B->SwitchFocus(M);
  28.   M.RtnCode = Idle; M.Code = Idle;
  29.   do {
  30.     B->SubMgr->EventStep(M);
  31.     M.Code = M.RtnCode;
  32.   } while (M.Code != ShutDown &&
  33.           (!B->Active || M.Code != Close || M.Focus != (Iso *)(B)));
  34.   if (M.Code == Close) {
  35.      B->OnClose(M);
  36.      Mouse.WaitForEvent(MouseUp, M.Mx, M.My);
  37.      M.RtnCode = Idle;
  38.   }
  39.   delete B; // Remove the window
  40.   // Control is now returned to the menu
  41. }
  42.  
  43. MesoList *MList;
  44. Meso *Entry1, *Entry2, *Entry3, *Entry4, *Entry5;
  45. Mso *Menu1;
  46.  
  47. main()
  48. {
  49.   // ------------------------Part 1------------------------------
  50.   DefColors = CyanColors;           // Setup the display colors 
  51.   Setup(MouseOptional, DefColors);  // Setup the environment 
  52.   MList = new MesoList;             // Create the menu list
  53.   // Add each menu entry to the list 
  54.   Entry1 = new Meso("New", PopupAction);
  55.   MList->Append(Entry1);
  56.   Entry2 = new Meso("Open", PopupAction);
  57.   MList->Append(Entry2);
  58.   Entry3 = new Meso("Save", PopupAction);
  59.   MList->Append(Entry3);
  60.   Entry4 = new Meso("Close", PopupAction);
  61.   MList->Append(Entry4);
  62.   Entry5 = new Meso("Exit", ExitAction);
  63.   MList->Append(Entry5);
  64.   // ---------------Part 2: Create the menu object----------------
  65.   Menu1 = new Mso(MList, 1, 5, 1, 15, 5, 0x11,
  66.                  WithShadow+Swappable, DefColors);
  67.   FullScrn->Panel->Clear(177,4);
  68.   Menu1->Open(FullScrn, 10, 5);
  69.   MainEventLoop();
  70.   CleanUp();
  71. }
  72.  
  73.